package cn.stylefeng.guns.modular.business.frequency.userawardbase.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.business.frequency.userawardbase.model.result.PkgUserAwardBase;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import cn.stylefeng.guns.modular.business.frequency.userawardbase.service.UserAwardBaseService;
import cn.stylefeng.guns.modular.business.frequency.userawardbase.model.param.UserAwardBaseParam;

import javax.annotation.Resource;
import java.util.List;

/**
 * 网点人员提成设置表 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:15
 */
@RestController
@RequestMapping("/api/award-setting")
public class UserAwardBaseController {

    @Resource
    private UserAwardBaseService userAwardBaseService;



    @ApiOperation(value = "网点ID查询用户奖励配置")
    @GetMapping("/site/{siteId}")
    public ResponseData getUserAwardBaseList(@PathVariable String siteId,
                                                                 @RequestParam(value = "month", required = false) String month) {
        List<PkgUserAwardBase> list = userAwardBaseService.getUserAwardBaseList(siteId, month);
        return ResponseData.andaSuccess(list);
    }

    /**
     * 分页查询网点人员提成设置表
     *
     * @author yujie
     * @date 2023/05/09 17:15
     */
    @GetMapping("/userAwardBase/page")
    @BusinessLog(title = "网点人员提成设置表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(UserAwardBaseParam userAwardBaseParam) {
        return userAwardBaseService.page(userAwardBaseParam);
    }

    /**
     * 获取全部网点人员提成设置表
     *
     * @author yujie
     * @date 2023/05/09 17:15
     */
    @GetMapping("/userAwardBase/list")
    @BusinessLog(title = "网点人员提成设置表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(UserAwardBaseParam userAwardBaseParam) {
        return ResponseData.andaSuccess(userAwardBaseService.list(userAwardBaseParam));
    }

    /**
     * 查看详情网点人员提成设置表
     *
     * @author yujie
     * @date 2023/05/09 17:15
     */
    @GetMapping("/userAwardBase/detail")
    @BusinessLog(title = "网点人员提成设置表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(UserAwardBaseParam.detail.class) UserAwardBaseParam userAwardBaseParam) {
        return ResponseData.andaSuccess(userAwardBaseService.detail(userAwardBaseParam));
    }

    /**
     * 添加网点人员提成设置表
     *
     * @author yujie
     * @date 2023/05/09 17:15
     */
    @PostMapping("/userAwardBase/add")
    @BusinessLog(title = "网点人员提成设置表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody  UserAwardBaseParam userAwardBaseParam) {
        StringBuilder errorMessage = new StringBuilder();
        if(userAwardBaseService.checkParam(userAwardBaseParam,errorMessage)){
           return ResponseData.andaError(errorMessage.toString());
        }
        userAwardBaseService.add(userAwardBaseParam);
        return ResponseData.andaSuccess();
    }

    /**
     * 删除网点人员提成设置表
     *
     * @author yujie
     * @date 2023/05/09 17:15
     */
    @PostMapping("/userAwardBase/delete")
    @BusinessLog(title = "网点人员提成设置表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody UserAwardBaseParam userAwardBaseParam) {
        userAwardBaseService.delete(userAwardBaseParam);
        return ResponseData.andaSuccess();
    }

    /**
     * 编辑网点人员提成设置表
     *
     * @author yujie
     * @date 2023/05/09 17:15
     */
    @PostMapping("/userAwardBase/edit")
    @BusinessLog(title = "网点人员提成设置表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody  UserAwardBaseParam userAwardBaseParam) {
        userAwardBaseService.edit(userAwardBaseParam);
        return ResponseData.andaSuccess();
    }

    /**
     * 修改状态
     *
     * @author yujie
     * @date 2023/05/09 17:15
     */
    @PostMapping("/userAwardBase/changeStatus")
    @BusinessLog(title = "网点人员提成设置表_修改状态", opType = LogAnnotionOpTypeEnum.CHANGE_STATUS)
    public ResponseData changeStatus(@RequestBody @Validated(UserAwardBaseParam.changeStatus.class) UserAwardBaseParam userAwardBaseParam) {
        userAwardBaseService.changeStatus(userAwardBaseParam);
        return new SuccessResponseData();
    }

}
